package com.jl.jlapp.mvp.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;

import com.jl.jlapp.R;
import com.jl.jlapp.mvp.fragment.InvoiceFragment;
import com.jl.jlapp.utils.Tools;

public class InvoiceActivity
  extends AppCompatActivity
{
  @BindView(R.id.return_btn)
  ImageView returnBtn;
  @BindView(R.id.tv_unit_invoice)
  TextView tv_unit_invoice;
  @BindView(R.id.tv_vat_invoice)
  TextView tv_vat_invoice;
  private InvoiceFragment unitInvoice;
  int userId = 0;
  private InvoiceFragment vatInvoice;
  
  private void initView()
  {
    this.vatInvoice = InvoiceFragment.newInstance(1, this.userId);
    this.unitInvoice = InvoiceFragment.newInstance(2, this.userId);
    getSupportFragmentManager().beginTransaction().add(R.id.lay_frame, this.vatInvoice).add(R.id.lay_frame, this.unitInvoice).show(this.vatInvoice).hide(this.unitInvoice).commitAllowingStateLoss();
    final Drawable localDrawable = getResources().getDrawable(R.drawable.splite_green);
    this.tv_vat_invoice.setCompoundDrawablesWithIntrinsicBounds(null, null, null, localDrawable);
    this.tv_unit_invoice.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    this.tv_vat_invoice.setOnClickListener(new OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        InvoiceActivity.this.getSupportFragmentManager().beginTransaction().show(InvoiceActivity.this.vatInvoice).hide(InvoiceActivity.this.unitInvoice).commitAllowingStateLoss();
        InvoiceActivity.this.tv_vat_invoice.setCompoundDrawablesWithIntrinsicBounds(null, null, null, localDrawable);
        InvoiceActivity.this.tv_unit_invoice.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
      }
    });
    this.tv_unit_invoice.setOnClickListener(new OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        InvoiceActivity.this.getSupportFragmentManager().beginTransaction().show(InvoiceActivity.this.unitInvoice).hide(InvoiceActivity.this.vatInvoice).commitAllowingStateLoss();
        InvoiceActivity.this.tv_vat_invoice.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        InvoiceActivity.this.tv_unit_invoice.setCompoundDrawablesWithIntrinsicBounds(null, null, null, localDrawable);
      }
    });
  }
  
  protected void onCreate(@Nullable Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(R.layout.activity_invoice);
    ButterKnife.bind(this);
    Tools.finishAll();
    this.returnBtn.setOnClickListener(new OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        InvoiceActivity.this.finish();
      }
    });
  }
  
  protected void onResume()
  {
    super.onResume();
    this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", 0);
    if (this.userId > 0)
    {
      initView();
      return;
    }
    Toast.makeText(this, "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
    startActivity(new Intent(this, LoginActivity.class));
  }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/InvoiceActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */